<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: base   board.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1316139452.16" />
	<link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1316139452.16" />

    <script type="text/javascript" src="assets/api-js?stamp=1316139452.16"></script>
    <script type="text/javascript" src="assets/ac-js?stamp=1316139452.16"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="g-javascript-lib">g-javascript-lib</a></h1>
        <h3>base&nbsp; <span class="subtitle">1.0.0</span></h3>
        <a href="./index.html" title="g-javascript-lib">g-javascript-lib</a> 
            &gt; <a href="./module_base.html" title="base">base</a>
                
                 &gt; board.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * @module svg</span>
<span class="cm"> */</span>
<span class="p">(</span><span class="kd">function</span><span class="p">()</span>
 <span class="p">{</span>
	<span class="kd">var</span> <span class="nx">SVG_NS</span> <span class="o">=</span> <span class="s2">&quot;http://www.w3.org/2000/svg&quot;</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">XLINK_NS</span> <span class="o">=</span> <span class="s2">&quot;http://www.w3.org/1999/xlink&quot;</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">MIN_GRIDS</span> <span class="o">=</span> <span class="mi">10</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">SCALE_MIN</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">SCALE_MAX</span> <span class="o">=</span> <span class="mi">10</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">DPIN</span> <span class="o">=</span> <span class="mi">1000</span><span class="p">;</span>	<span class="c1">// 1000 dot per inch</span>
	<span class="kd">var</span> <span class="nx">DPMN</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>		<span class="c1">// 100 dot per mm</span>

	<span class="kd">var</span> <span class="nx">DOT_PER_UNIT</span> <span class="o">=</span> <span class="p">{</span>
		<span class="s1">&#39;in&#39;</span><span class="o">:</span>	<span class="mi">1000</span><span class="p">,</span>
		<span class="s1">&#39;mil&#39;</span><span class="o">:</span>	<span class="mi">1</span><span class="p">,</span>
		<span class="s1">&#39;mm&#39;</span><span class="o">:</span>	<span class="mi">100</span><span class="p">,</span>
		<span class="s1">&#39;cm&#39;</span><span class="o">:</span>	<span class="mi">1000</span>
	<span class="p">}</span>
	<span class="cm">/**</span>
<span class="cm">	 * A drawing board in SVG.</span>
<span class="cm">	 * @namespace SVG</span>
<span class="cm">	 * @class Board</span>
<span class="cm">	 */</span>
	<span class="kd">var</span> <span class="nx">SVGBoard</span> <span class="o">=</span> <span class="nx">G</span><span class="p">.</span><span class="nx">GClass</span><span class="p">(</span><span class="s1">&#39;SVG&#39;</span><span class="p">,</span> <span class="s1">&#39;Board&#39;</span><span class="p">,</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">);</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__init</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">bw</span><span class="p">,</span> <span class="nx">bh</span><span class="p">,</span> <span class="nx">u</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">__Base__EventListener__init</span><span class="p">();</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_showGrid</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_snapGrid</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_drawGrid</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_mirror</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

		<span class="c1">// Inital Dot per Unit</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_unit</span> <span class="o">=</span> <span class="nx">u</span> <span class="o">||</span> <span class="s1">&#39;mil&#39;</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_unit</span> <span class="k">in</span> <span class="nx">DOT_PER_UNIT</span><span class="p">)</span> <span class="p">{</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_unit</span> <span class="o">=</span> <span class="s1">&#39;mil&#39;</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_dpu</span> <span class="o">=</span> <span class="nx">DOT_PER_UNIT</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">_unit</span><span class="p">];</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scaleRate</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scaleStep</span> <span class="o">=</span> <span class="mi">10</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_viewX</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_viewY</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_viewW</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_viewH</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_symbols</span> <span class="o">=</span> <span class="p">[];</span>

		<span class="c1">// Board Size</span>
		<span class="nx">bw</span> <span class="o">=</span> <span class="nx">bw</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_dpu</span><span class="p">;</span>
		<span class="nx">bh</span> <span class="o">=</span> <span class="nx">bh</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_dpu</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_width</span> <span class="o">=</span> <span class="nx">bw</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_heigth</span> <span class="o">=</span> <span class="nx">bh</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">((</span><span class="nx">bw</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span><span class="p">)</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">((</span><span class="nx">bh</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span><span class="p">)</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_viewX</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_viewY</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_selected</span> <span class="o">=</span> <span class="p">[];</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_objects</span> <span class="o">=</span> <span class="p">[];</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_objectId</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_symbleUsed</span> <span class="o">=</span> <span class="p">{};</span>	<span class="c1">// Use count for symbles.</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_symbles</span> <span class="o">=</span> <span class="p">{};</span>		<span class="c1">// </span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_undoStack</span> <span class="o">=</span> <span class="p">[];</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_undoIndex</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_keycmd</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Widget</span><span class="p">.</span><span class="nx">KeyCommander</span><span class="p">();</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_keycmd</span><span class="p">.</span><span class="nx">enable</span><span class="p">();</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Load short-cut key command list</span>
<span class="cm">	 * @method load_hot_key</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">load_hot_key</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">cmdlist</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_keycmd</span><span class="p">.</span><span class="nx">load_cmd_list</span><span class="p">(</span><span class="nx">cmdlist</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Create SVG element into the container.</span>
<span class="cm">	 * @method render</span>
<span class="cm">	 * @param container {DOM Element}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">render</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">container</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">div</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;div&#39;</span><span class="p">);</span>
		<span class="nx">div</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="s1">&#39;svgboard&#39;</span><span class="p">;</span>
		<span class="nx">container</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">div</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emFrameDiv</span> <span class="o">=</span> <span class="nx">div</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">svg</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;svg&#39;</span><span class="p">);</span> 
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;width&quot;</span><span class="p">,</span> <span class="s2">&quot;100%&quot;</span><span class="p">);</span>
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s2">&quot;height&quot;</span><span class="p">,</span> <span class="s2">&quot;100%&quot;</span><span class="p">);</span>
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;version&#39;</span><span class="p">,</span> <span class="s1">&#39;1.1&#39;</span><span class="p">);</span>
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;float&#39;</span><span class="p">,</span> <span class="s1">&#39;left&#39;</span><span class="p">);</span>
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;display&#39;</span><span class="p">,</span> <span class="s1">&#39;block&#39;</span><span class="p">);</span>
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;xmlns&#39;</span><span class="p">,</span> <span class="nx">SVG_NS</span><span class="p">);</span>
		<span class="nx">svg</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;xmlns:xlink&#39;</span><span class="p">,</span> <span class="nx">XLINK_NS</span><span class="p">);</span>
		<span class="nx">div</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">svg</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span> <span class="o">=</span> <span class="nx">G</span><span class="p">(</span><span class="nx">svg</span><span class="p">);</span>

		<span class="c1">// Create defs</span>
		<span class="kd">var</span> <span class="nx">defs</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;defs&#39;</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">defs</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emDefs</span> <span class="o">=</span> <span class="nx">defs</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_draw_grid</span><span class="p">();</span>

		<span class="c1">// Create background</span>
		<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="p">{</span> <span class="nx">width</span><span class="o">:</span> <span class="s1">&#39;100%&#39;</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span><span class="s1">&#39;100%&#39;</span><span class="p">,</span> <span class="s1">&#39;class&#39;</span><span class="o">:</span> <span class="s1">&#39;background&#39;</span><span class="p">});</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">g</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emBackBox</span> <span class="o">=</span> <span class="nx">g</span><span class="p">;</span>

		<span class="c1">// Create drawbox</span>
		<span class="nx">g</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="p">{</span> <span class="nx">width</span><span class="o">:</span> <span class="s1">&#39;100%&#39;</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span><span class="s1">&#39;100%&#39;</span><span class="p">,</span> <span class="s1">&#39;class&#39;</span><span class="o">:</span> <span class="s1">&#39;drawbox&#39;</span><span class="p">});</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span> <span class="o">=</span> <span class="nx">g</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_draw_cursor</span><span class="p">();</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">g</span><span class="p">);</span>

		<span class="nx">rect</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;rect&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;class&#39;</span><span class="o">:</span> <span class="s1">&#39;canvas&#39;</span><span class="p">,</span> <span class="nx">width</span><span class="o">:</span><span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">});</span>
		<span class="nx">g</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">rect</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCanvas</span> <span class="o">=</span> <span class="nx">rect</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_update_scale_range</span><span class="p">();</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">x</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="mi">0</span><span class="p">};</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">zoom_fit</span><span class="p">();</span>

		<span class="nx">G</span><span class="p">(</span><span class="nx">div</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onresize&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_on_resize</span><span class="p">,</span> <span class="k">this</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onmousedown&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_on_mouse_down</span><span class="p">,</span> <span class="k">this</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onmouseup&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_on_mouse_up</span><span class="p">,</span> <span class="k">this</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onmousemove&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_on_mouse_move</span><span class="p">,</span> <span class="k">this</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onclick&quot;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_on_click</span><span class="p">,</span> <span class="k">this</span><span class="p">);</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Set the size of svg board&#39;s. the SVGBoard will adjust the scale</span>
<span class="cm">	 * range to fit the new size of board.</span>
<span class="cm">	 * @method set_size</span>
<span class="cm">	 * @param w {integer} width</span>
<span class="cm">	 * @param h {integer} height</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_size</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">w</span><span class="p">,</span> <span class="nx">h</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span> <span class="o">=</span> <span class="nx">w</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span> <span class="o">=</span> <span class="nx">h</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCanvas</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;width&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCanvas</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;height&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">);</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorH</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;x2&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorV</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;y2&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">);</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_update_scale_range</span><span class="p">();</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">x</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="mi">0</span><span class="p">};</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">zoom_fit</span><span class="p">();</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_class</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">classname</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">classname</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Draw the cross line as cursor.</span>
<span class="cm">	 * @method _draw_cursor</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_draw_cursor</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span> <span class="o">/</span> <span class="mi">2</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span> <span class="o">/</span> <span class="mi">2</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;class&#39;</span><span class="o">:</span> <span class="s1">&#39;cursorbox&#39;</span><span class="p">});</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorH</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;line&#39;</span><span class="p">,</span> 
				<span class="p">{</span><span class="nx">x1</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">y1</span><span class="o">:</span> <span class="nx">y</span><span class="p">,</span> <span class="nx">x2</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">,</span> <span class="nx">y2</span><span class="o">:</span> <span class="nx">y</span><span class="p">});</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorV</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;line&#39;</span><span class="p">,</span> 
				<span class="p">{</span><span class="nx">x1</span><span class="o">:</span> <span class="nx">x</span><span class="p">,</span> <span class="nx">y1</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">x2</span><span class="o">:</span> <span class="nx">x</span><span class="p">,</span> <span class="nx">y2</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">});</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_emCursorH</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_emCursorV</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorBox</span> <span class="o">=</span> <span class="nx">g</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">g</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Draw the grid box. The grid box include a background rect to show grid</span>
<span class="cm">	 * and a cross line as cursor.</span>
<span class="cm">	 * @method _draw_grid</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_draw_grid</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">)</span>	<span class="k">return</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">ptn</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;pattern&#39;</span><span class="p">,</span> <span class="p">{</span><span class="nx">id</span><span class="o">:</span> <span class="s1">&#39;grid&#39;</span><span class="p">,</span> <span class="nx">width</span><span class="o">:</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">patternUnits</span><span class="o">:</span> <span class="s1">&#39;userSpaceOnUse&#39;</span><span class="p">});</span>
		<span class="kd">var</span> <span class="nx">rect</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;rect&#39;</span><span class="p">,</span> <span class="p">{</span><span class="nx">width</span><span class="o">:</span><span class="nx">w</span><span class="o">+</span><span class="mf">0.5</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span><span class="nx">w</span><span class="o">+</span><span class="mf">0.5</span><span class="p">,</span> <span class="nx">stroke</span><span class="o">:</span><span class="s1">&#39;#030&#39;</span><span class="p">,</span> <span class="s1">&#39;stroke-width&#39;</span><span class="o">:</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;shapeRendering&#39;</span><span class="o">:</span> <span class="s1">&#39;crispEdges&#39;</span><span class="p">,</span> <span class="nx">fill</span><span class="o">:</span> <span class="s1">&#39;none&#39;</span><span class="p">});</span>

		<span class="nx">ptn</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">rect</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emGridElement</span> <span class="o">=</span> <span class="nx">rect</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emDefs</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">ptn</span><span class="p">);</span>


		<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;class&#39;</span><span class="o">:</span><span class="s1">&#39;gridbox&#39;</span><span class="p">,</span> <span class="nx">width</span><span class="o">:</span><span class="s1">&#39;100%&#39;</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span><span class="s1">&#39;100%&#39;</span><span class="p">});</span>
		<span class="kd">var</span> <span class="nx">b</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;rect&#39;</span><span class="p">,</span> <span class="p">{</span> <span class="nx">width</span><span class="o">:</span> <span class="s1">&#39;100%&#39;</span><span class="p">,</span> <span class="nx">height</span><span class="o">:</span><span class="s1">&#39;100%&#39;</span><span class="p">});</span>
		<span class="nx">g</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">b</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">g</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emGridRect</span> <span class="o">=</span> <span class="nx">b</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emGridBox</span> <span class="o">=</span> <span class="nx">g</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * This funciton will calculate the MIN, MAX and FIT scale of the board.</span>
<span class="cm">	 * The minimum of scale to make sure the whole draw board can be fit into </span>
<span class="cm">	 * window, but the value must be in the range of 0.001 -- 1.&lt;/br&gt;</span>
<span class="cm">	 * The fit scale will make the whole board displayed into the view area.</span>
<span class="cm">	 *</span>
<span class="cm">	 * When zoom in/out, if the scale was set into the range of 0.1 -- 1, </span>
<span class="cm">	 * it must be regulate to multiple of 0.1 to avoid the deviation of grid.</span>
<span class="cm">	 * The size of grid is always multiple of 10.</span>
<span class="cm">	 *</span>
<span class="cm">	 * if the scale was set to smaller than 0.1, the grid will dispared.</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method _update_scale_range</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_update_scale_range</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="c1">//var cw = this._svg.em.clientWidth;</span>
		<span class="c1">//var ch = this._svg.em.clientHeight;</span>
		<span class="kd">var</span> <span class="nx">cw</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emFrameDiv</span><span class="p">.</span><span class="nx">clientWidth</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">ch</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emFrameDiv</span><span class="p">.</span><span class="nx">clientHeight</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">&lt;</span> <span class="mi">200</span><span class="p">)</span>	<span class="nx">ch</span> <span class="o">=</span> <span class="mi">200</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">cw</span> <span class="o">&lt;</span> <span class="mi">200</span><span class="p">)</span>	<span class="nx">cw</span> <span class="o">=</span> <span class="mi">200</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">scaleW</span> <span class="o">=</span> <span class="nx">cw</span> <span class="o">/</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">scaleH</span> <span class="o">=</span> <span class="nx">ch</span> <span class="o">/</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">scale</span> <span class="o">=</span><span class="p">(</span><span class="nx">scaleW</span> <span class="o">&lt;</span> <span class="nx">scaleH</span><span class="p">)</span><span class="o">?</span>	<span class="nx">scaleW</span> <span class="o">:</span> <span class="nx">scaleH</span><span class="p">;</span>

		<span class="c1">// We can always scale to 1:1;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span> <span class="o">=</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">)</span><span class="o">?</span> <span class="mi">1</span> <span class="o">:</span> <span class="nx">scale</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&lt;</span> <span class="mf">0.1</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&lt;</span> <span class="nx">SCALE_MIN</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">scale</span> <span class="o">=</span> <span class="nx">SCALE_MIN</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&lt;</span> <span class="mf">0.1</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">scale</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nx">scale</span> <span class="o">*</span> <span class="mi">10</span><span class="p">)</span> <span class="o">/</span> <span class="mi">10</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scaleMax</span> <span class="o">=</span> <span class="nx">SCALE_MAX</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">rate</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">SCALE_MAX</span> <span class="o">/</span> <span class="nx">scale</span><span class="p">)</span> <span class="o">/</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_scaleStep</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scaleRate</span> <span class="o">=</span> <span class="nx">rate</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Set how many steps to zoom the scale from minimum to maximum.</span>
<span class="cm">	 * The default step is 10.</span>
<span class="cm">	 * @method set_scale_step</span>
<span class="cm">	 * @param &lt;integer&gt; step</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_scale_step</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">step</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">step</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">)</span>	<span class="nx">step</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_scaleStep</span> <span class="o">=</span> <span class="nx">step</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_update_scale_range</span><span class="p">();</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * When the size of svg container was changed,  we need calculate the</span>
<span class="cm">	 * scale range again.</span>
<span class="cm">	 * @method _on_resize</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_on_resize</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evt</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_update_scale_range</span><span class="p">();</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">zoom_fit</span><span class="p">();</span>
		<span class="p">}</span>
	<span class="p">}</span>


	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_create_element</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">typ</span><span class="p">,</span> <span class="nx">attr</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">attr</span> <span class="o">=</span> <span class="nx">attr</span> <span class="o">||</span> <span class="kc">null</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">typ</span><span class="p">)</span> <span class="o">!=</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">typ</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="k">if</span> <span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">createElementNS</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElementNS</span><span class="p">(</span><span class="nx">SVG_NS</span><span class="p">,</span> <span class="nx">typ</span><span class="p">);</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="nx">typ</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">attr</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">attr</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">o</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">attr</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
			<span class="p">}</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="nx">o</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Set the grid size. the grid size must be a multiply of 10.</span>
<span class="cm">	 * to avoid the deviation when zoom in/out.</span>
<span class="cm">	 * @method set_grid</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_grid</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">grid</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">grid</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nx">grid</span> <span class="o">/</span> <span class="mi">10</span><span class="p">)</span> <span class="o">*</span> <span class="mi">10</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">grid</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="p">)</span>	<span class="nx">grid</span> <span class="o">=</span> <span class="mi">10</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span> <span class="o">=</span> <span class="nx">grid</span><span class="p">;</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">_emGridElement</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;width&#39;</span><span class="p">,</span> <span class="nx">grid</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emGridElement</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;height&#39;</span><span class="p">,</span> <span class="nx">grid</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Set the grid on/off</span>
<span class="cm">	 * @method view_grid</span>
<span class="cm">	 * @param on {boolean}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">view_grid</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">on</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">on</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emGridElement</span><span class="p">.</span><span class="nx">removeAttribute</span><span class="p">(</span><span class="s1">&#39;display&#39;</span><span class="p">);</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emGridElement</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;display&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Fix the value of coordinate to align on grid.</span>
<span class="cm">	 * @method _snap_to_grid</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_snap_to_grid</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="p">,</span> <span class="nx">grid</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">grid</span> <span class="o">=</span> <span class="nx">grid</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">_drawGrid</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">x</span>  <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">round</span><span class="p">(</span><span class="nx">x</span> <span class="o">/</span> <span class="nx">grid</span><span class="p">)</span> <span class="o">*</span> <span class="nx">grid</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">y</span>  <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">round</span><span class="p">(</span><span class="nx">y</span> <span class="o">/</span> <span class="nx">grid</span><span class="p">)</span> <span class="o">*</span> <span class="nx">grid</span><span class="p">;</span>
		<span class="k">return</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span> <span class="nx">x</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="nx">y</span><span class="p">};</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Get the point of mouse event in board&#39;s coordinate system.</span>
<span class="cm">	 * @method _map_mouse_matrix</span>
<span class="cm">	 * @param evt {mouse event}</span>
<span class="cm">	 * @return {x,y} the X,Y value of coordinate.</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_map_mouse_matrix</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evt</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">CTM</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">getCTM</span><span class="p">();</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_svg</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">createSVGPoint</span><span class="p">();</span>
		<span class="nx">p</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="nx">evt</span><span class="p">.</span><span class="nx">offsetX</span> <span class="o">||</span> <span class="nx">evt</span><span class="p">.</span><span class="nx">layerX</span><span class="p">;</span>
		<span class="nx">p</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="nx">evt</span><span class="p">.</span><span class="nx">offsetY</span> <span class="o">||</span> <span class="nx">evt</span><span class="p">.</span><span class="nx">layerY</span><span class="p">;</span>
		<span class="c1">//console.log(&#39;evt: &#39; + p.x + &#39;,&#39; + p.y);</span>
		<span class="kd">var</span> <span class="nx">p2</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">matrixTransform</span><span class="p">(</span><span class="nx">CTM</span><span class="p">.</span><span class="nx">inverse</span><span class="p">());</span>
		
		<span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_snap_to_grid</span><span class="p">(</span><span class="nx">p2</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span> <span class="nx">p2</span><span class="p">.</span><span class="nx">y</span><span class="p">);</span>
		<span class="c1">//console.log(&#39;mouse: &#39; + p.x + &#39;,&#39; + p.y);</span>
		<span class="k">return</span> <span class="nx">p</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Mirror the board.</span>
<span class="cm">	 * @method mirror</span>
<span class="cm">	 * @param mirror {boolean}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">mirror</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">mirror</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">mirror</span> <span class="o">!=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_mirror</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_mirror</span> <span class="o">=</span> <span class="nx">mirror</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_update_matrix</span><span class="p">();</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Update the transform matrix according the scale, offset and mirror </span>
<span class="cm">	 * status of the board.</span>
<span class="cm">	 * @method _update_matrix</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_update_matrix</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
		<span class="c1">// Xn = X * m0 + Y * m2 + m4 </span>
		<span class="c1">// Yn = X * m1 + Y * m3 + m5</span>
		<span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="p">[];</span>
		<span class="nx">m</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="nx">m</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="nx">m</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">cx</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">x</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">cy</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">y</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewGrid</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">;</span>
		<span class="c1">//var w = Math.floor(this._svg.em.clientWidth / g / 2) * g;</span>
		<span class="c1">//var h = Math.floor(this._svg.em.clientHeight / g / 2) * g;</span>
		<span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_emFrameDiv</span><span class="p">.</span><span class="nx">clientWidth</span> <span class="o">/</span> <span class="nx">g</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> <span class="o">*</span> <span class="nx">g</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">h</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_emFrameDiv</span><span class="p">.</span><span class="nx">clientHeight</span> <span class="o">/</span> <span class="nx">g</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> <span class="o">*</span> <span class="nx">g</span><span class="p">;</span>

		<span class="nx">m</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">=</span> <span class="nx">h</span> <span class="o">-</span> <span class="nx">cy</span><span class="p">;</span>	<span class="c1">// Offset Y</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mirror</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">m</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>  <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">*</span> <span class="mi">1000</span><span class="p">)</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">;</span>
			<span class="nx">m</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="nx">w</span> <span class="o">+</span> <span class="nx">cx</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="nx">m</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">;</span>
			<span class="nx">m</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">=</span> <span class="nx">w</span> <span class="o">-</span> <span class="nx">cx</span><span class="p">;</span>
		<span class="p">}</span>

		<span class="kd">var</span> <span class="nx">matrix</span> <span class="o">=</span> <span class="s1">&#39;matrix(&#39;</span> <span class="o">+</span> <span class="nx">m</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;transform&#39;</span><span class="p">,</span> <span class="nx">matrix</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emBackBox</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;transform&#39;</span><span class="p">,</span> <span class="nx">matrix</span><span class="p">);</span>
		<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">matrix</span><span class="p">);</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Move and scale the view window.</span>
<span class="cm">	 * @method set_view</span>
<span class="cm">	 * @param scale {float}</span>
<span class="cm">	 * @param center {integer} the center of the view area, the value</span>
<span class="cm">	 * will be fixed to align to grid.</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_view</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">scale</span><span class="p">,</span> <span class="nx">center</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="c1">// Recalculate the view box size if scale changed.</span>
		<span class="kd">var</span> <span class="nx">update</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">scale</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleMin</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleMax</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">scale</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleMax</span><span class="p">;</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">center</span><span class="p">.</span><span class="nx">x</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>	<span class="nx">center</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">center</span><span class="p">.</span><span class="nx">y</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>	<span class="nx">center</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">center</span><span class="p">.</span><span class="nx">x</span> <span class="o">&gt;=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">)</span>	<span class="nx">center</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">center</span><span class="p">.</span><span class="nx">y</span> <span class="o">&gt;=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">)</span>	<span class="nx">center</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">;</span>

		<span class="nx">cp</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_snap_to_grid</span><span class="p">(</span><span class="nx">center</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span> <span class="nx">center</span><span class="p">.</span><span class="nx">y</span><span class="p">);</span>	<span class="c1">// Center point</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">!=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">)</span> 
		<span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">=</span> <span class="nx">scale</span><span class="p">;</span>
			<span class="nx">update</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>

			<span class="c1">// Resize the grid box and cursor box the make it full fill the window.</span>
			<span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="s1">&#39;100%&#39;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">i</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">round</span><span class="p">(</span><span class="mi">100</span> <span class="o">/</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;%&#39;</span><span class="p">;</span>
			<span class="p">}</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emGridRect</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;width&#39;</span><span class="p">,</span> <span class="nx">i</span><span class="p">);</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emGridRect</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;height&#39;</span><span class="p">,</span> <span class="nx">i</span><span class="p">);</span>

			<span class="kd">var</span> <span class="nx">tr</span> <span class="o">=</span> <span class="s1">&#39;scale(&#39;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emGridBox</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;transform&#39;</span><span class="p">,</span> <span class="nx">tr</span><span class="p">);</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorBox</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;transform&#39;</span><span class="p">,</span> <span class="nx">tr</span><span class="p">);</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">((</span><span class="nx">cp</span><span class="p">.</span><span class="nx">x</span> <span class="o">!=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">x</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="nx">cp</span><span class="p">.</span><span class="nx">y</span> <span class="o">!=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">y</span><span class="p">)</span> <span class="o">||</span> <span class="nx">update</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="nx">cp</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="nx">cp</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_update_matrix</span><span class="p">();</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">return</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="s1">&#39;onscalechanged&#39;</span><span class="p">,</span> <span class="p">{</span><span class="nx">scale</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scale</span><span class="p">,</span> <span class="nx">x</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewX</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_viewY</span><span class="p">});</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Zoom the board to fit the view area.</span>
<span class="cm">	 * @method zoom_fit</span>
<span class="cm">	 */</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">zoom_fit</span><span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span> <span class="o">/</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span> <span class="o">/</span> <span class="mi">2</span><span class="p">};</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">set_view</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_scaleFit</span><span class="p">,</span> <span class="nx">p</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Make sure the scale was a multiple of 0.1 if it&#39;s greater than 0.1</span>
<span class="cm">	 * @method _fix_scale</span>
<span class="cm">	 * @param scale {float}</span>
<span class="cm">	 * @return {float}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_fix_scale</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">scale</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">scale</span> <span class="o">&gt;=</span> <span class="mf">0.1</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">scale</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">(</span><span class="nx">scale</span> <span class="o">*</span> <span class="mi">10</span><span class="p">)</span> <span class="o">/</span> <span class="mi">10</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="nx">scale</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">zoom_in</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">scale</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_fix_scale</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleRate</span><span class="p">);</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">set_view</span><span class="p">(</span><span class="nx">scale</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">zoom_out</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">scale</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_fix_scale</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_scale</span> <span class="o">/</span> <span class="k">this</span><span class="p">.</span><span class="nx">_scaleRate</span><span class="p">);</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">set_view</span><span class="p">(</span><span class="nx">scale</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/* ======================================================================</span>
<span class="cm">	 * Edit commands</span>
<span class="cm">	 * ======================================================================</span>
<span class="cm">	 */</span>

	<span class="cm">/**</span>
<span class="cm">	 * Append an element into the draw box.</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method add_element</span>
<span class="cm">	 * @param shp {string} the tag name of the element</span>
<span class="cm">	 * @param attr {object} the attributes of the element</span>
<span class="cm">	 * @param p {SVG Element} the father of the element, default to draw box</span>
<span class="cm">	 * @return {SVG Element}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">add_element</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">shp</span><span class="p">,</span> <span class="nx">attr</span><span class="p">,</span> <span class="nx">p</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">p</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">em</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="nx">shp</span><span class="p">,</span> <span class="nx">attr</span><span class="p">);</span>
		<span class="nx">p</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">em</span><span class="p">);</span>
		<span class="k">return</span> <span class="nx">em</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Remove an element.</span>
<span class="cm">	 * @method remove_element</span>
<span class="cm">	 * @param em {SVG Element}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">remove_element</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">em</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">em</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">p</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">p</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="nx">em</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Append a SVG element into background.</span>
<span class="cm">	 * @method add_background</span>
<span class="cm">	 * @param shp {string} the tag name of the element</span>
<span class="cm">	 * @param attr {object} the attributes of the element</span>
<span class="cm">	 * @param p {SVG Element} the father of the element, default to background box.</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">add_background</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">shp</span><span class="p">,</span> <span class="nx">attr</span><span class="p">,</span> <span class="nx">p</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">p</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emBackBox</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">em</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="nx">shp</span><span class="p">,</span> <span class="nx">attr</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emBackBox</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">em</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Add an element into defs with a name.</span>
<span class="cm">	 * @method def_symbol</span>
<span class="cm">	 * @param name {string} the name of the defined element.</span>
<span class="cm">	 * @param tag {string} the tag name of the element default to &#39;g&#39;</span>
<span class="cm">	 * @param attr {string} the attribute of the element</span>
<span class="cm">	 * @return {SVG element}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">def_symbol</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">tag</span><span class="p">,</span> <span class="nx">attr</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">tag</span> <span class="o">=</span> <span class="nx">tag</span> <span class="o">||</span> <span class="s1">&#39;g&#39;</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">attr</span> <span class="o">=</span> <span class="nx">attr</span> <span class="o">||</span> <span class="p">{};</span>
		<span class="nx">attr</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">em</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="nx">tag</span><span class="p">,</span> <span class="nx">attr</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_emDefs</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">em</span><span class="p">);</span>

		<span class="k">return</span> <span class="nx">em</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Add a use to the predefined symbol.</span>
<span class="cm">	 * @method add_use</span>
<span class="cm">	 * @param symName {string} the name of symbol to use.</span>
<span class="cm">	 * @param attr {string} the attribute of the element;</span>
<span class="cm">	 * @param parent {SVG Element} the parent node of the element.</span>
<span class="cm">	 * @return {SVG Element}</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">add_use</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">symName</span><span class="p">,</span> <span class="nx">attr</span><span class="p">,</span> <span class="nx">parent</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">em</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;use&#39;</span><span class="p">);</span>
		<span class="kd">var</span> <span class="nx">parent</span> <span class="o">=</span> <span class="nx">parent</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">;</span>
		<span class="nx">em</span><span class="p">.</span><span class="nx">setAttributeNS</span><span class="p">(</span><span class="nx">XLINK_NS</span><span class="p">,</span> <span class="s1">&#39;xlink:href&#39;</span><span class="p">,</span> <span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">symName</span><span class="p">);</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">a</span> <span class="k">in</span> <span class="nx">attr</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">em</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">attr</span><span class="p">[</span><span class="nx">a</span><span class="p">]);</span>
		<span class="p">}</span>
		<span class="nx">parent</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">em</span><span class="p">);</span>
		<span class="k">return</span> <span class="nx">em</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_json_svg_element</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">em</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;tag&#39;</span><span class="o">:</span> <span class="nx">em</span><span class="p">.</span><span class="nx">tagName</span><span class="p">};</span>
		<span class="nx">o</span><span class="p">.</span><span class="nx">attr</span> <span class="o">=</span> <span class="nx">em</span><span class="p">.</span><span class="nx">attributes</span><span class="p">;</span>

		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">o</span><span class="p">.</span><span class="nx">childs</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_json_svg_element</span><span class="p">(</span><span class="nx">em</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="nx">o</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_json</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;tag&#39;</span><span class="o">:</span> <span class="s1">&#39;g&#39;</span><span class="p">};</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">o</span><span class="p">.</span><span class="nx">childs</span><span class="p">[</span><span class="nx">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_json_svg_element</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
	<span class="p">}</span>


	<span class="cm">/**</span>
<span class="cm">	 * Move the cursor in the coordinate system of board.</span>
<span class="cm">	 * @method move_cursor</span>
<span class="cm">	 * @param p {point} The x/y value of the target position.</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">move_cursor</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">p</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">((</span><span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">x</span> <span class="o">!=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">x</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span><span class="p">.</span><span class="nx">y</span> <span class="o">!=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">y</span><span class="p">))</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="s1">&#39;oncursormove&#39;</span><span class="p">,</span> <span class="nx">p</span><span class="p">);</span>
			<span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
			<span class="kd">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">x</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">)</span>	<span class="nx">x</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardW</span><span class="p">;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">x</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>	<span class="nx">x</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">y</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">)</span>	<span class="nx">y</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_boardH</span><span class="p">;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">y</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span>	<span class="nx">y</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

			<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorV</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;x1&#39;</span><span class="p">,</span> <span class="nx">x</span><span class="o">+</span><span class="mf">0.5</span><span class="p">);</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorV</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;x2&#39;</span><span class="p">,</span> <span class="nx">x</span><span class="o">+</span><span class="mf">0.5</span><span class="p">);</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorH</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;y1&#39;</span><span class="p">,</span> <span class="nx">y</span><span class="o">+</span><span class="mf">0.5</span><span class="p">);</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emCursorH</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;y2&#39;</span><span class="p">,</span> <span class="nx">y</span><span class="o">+</span><span class="mf">0.5</span><span class="p">);</span>
		<span class="p">}</span> 
		<span class="k">this</span><span class="p">.</span><span class="nx">_cursor</span> <span class="o">=</span> <span class="nx">p</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/*</span>
<span class="cm">	 * Mouse Event handlers</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_on_mouse_down</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_map_mouse_matrix</span><span class="p">(</span><span class="nx">ev</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">move_cursor</span><span class="p">(</span><span class="nx">p</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">)</span>		<span class="k">return</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">act</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">onmousedown</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">act</span><span class="p">.</span><span class="nx">onmousemove</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">p</span><span class="p">,</span> <span class="nx">ev</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_on_mouse_move</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_map_mouse_matrix</span><span class="p">(</span><span class="nx">ev</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">move_cursor</span><span class="p">(</span><span class="nx">p</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">)</span>		<span class="k">return</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">act</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">onmousemove</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">act</span><span class="p">.</span><span class="nx">onmousemove</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">p</span><span class="p">,</span> <span class="nx">ev</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_on_mouse_up</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evt</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_map_mouse_matrix</span><span class="p">(</span><span class="nx">evt</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">move_cursor</span><span class="p">(</span><span class="nx">p</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">)</span>		<span class="k">return</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">act</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">onmouseup</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">act</span><span class="p">.</span><span class="nx">onmouseup</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">p</span><span class="p">,</span> <span class="nx">evt</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_on_click</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evt</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_map_mouse_matrix</span><span class="p">(</span><span class="nx">evt</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">move_cursor</span><span class="p">(</span><span class="nx">p</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">)</span>		<span class="k">return</span><span class="p">;</span>

		<span class="kd">var</span> <span class="nx">act</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">onclick</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">act</span><span class="p">.</span><span class="nx">onclick</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">act</span><span class="p">.</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">p</span><span class="p">,</span> <span class="nx">evt</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">set_mouse_action</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">action</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">.</span><span class="nx">deinit</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">))</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">.</span><span class="nx">deinit</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">.</span><span class="nx">obj</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span> <span class="o">=</span> <span class="nx">action</span><span class="p">;</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="k">typeof</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">.</span><span class="nx">init</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;function&#39;</span><span class="p">))</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">.</span><span class="nx">init</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_mouseAction</span><span class="p">.</span><span class="nx">obj</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">action</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="s1">&#39;ondrawmodechanged&#39;</span><span class="p">,</span> <span class="nx">action</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="s1">&#39;ondrawmodechanged&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>


	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">fly_line</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">point</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span> <span class="o">=</span> <span class="nx">point</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">)</span> <span class="p">{</span>
				<span class="kd">var</span> <span class="nx">line</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;line&#39;</span><span class="p">,</span> <span class="p">{</span>
					<span class="nx">x1</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span>
					<span class="nx">y1</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span>
					<span class="nx">x2</span><span class="o">:</span> <span class="nx">point</span><span class="p">.</span><span class="nx">x</span><span class="p">,</span>
					<span class="nx">y2</span><span class="o">:</span> <span class="nx">point</span><span class="p">.</span><span class="nx">y</span><span class="p">,</span>
					<span class="s1">&#39;class&#39;</span><span class="o">:</span> <span class="s1">&#39;fly&#39;</span>
				<span class="p">});</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span> <span class="o">=</span> <span class="nx">line</span><span class="p">;</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;x2&#39;</span><span class="p">,</span> <span class="nx">point</span><span class="p">.</span><span class="nx">x</span><span class="p">);</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="s1">&#39;y2&#39;</span><span class="p">,</span> <span class="nx">point</span><span class="p">.</span><span class="nx">y</span><span class="p">);</span>
			<span class="p">}</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">;</span>
	<span class="p">}</span>



	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">fly_rect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">point</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span> <span class="o">=</span> <span class="nx">point</span><span class="p">;</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">attr</span> <span class="o">=</span> <span class="p">{};</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">point</span><span class="p">.</span><span class="nx">x</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">x</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">attr</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="nx">point</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
				<span class="nx">attr</span><span class="p">.</span><span class="nx">width</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">x</span> <span class="o">-</span> <span class="nx">point</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="nx">attr</span><span class="p">.</span><span class="nx">width</span> <span class="o">=</span> <span class="nx">point</span><span class="p">.</span><span class="nx">x</span> <span class="o">-</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
				<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">)</span> <span class="nx">attr</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
			<span class="p">}</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">point</span><span class="p">.</span><span class="nx">y</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">y</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">attr</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="nx">point</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
				<span class="nx">attr</span><span class="p">.</span><span class="nx">height</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">y</span> <span class="o">-</span> <span class="nx">point</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="nx">attr</span><span class="p">.</span><span class="nx">height</span> <span class="o">=</span> <span class="nx">point</span><span class="p">.</span><span class="nx">y</span> <span class="o">-</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
				<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">)</span> <span class="nx">attr</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>
			<span class="p">}</span>

			<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">attr</span><span class="p">[</span><span class="s1">&#39;class&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;fly&#39;</span><span class="p">;</span>
				<span class="kd">var</span> <span class="nx">rect</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_create_element</span><span class="p">(</span><span class="s1">&#39;rect&#39;</span><span class="p">,</span> <span class="nx">attr</span><span class="p">);</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span> <span class="o">=</span> <span class="nx">rect</span><span class="p">;</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">rect</span><span class="p">);</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">a</span> <span class="k">in</span> <span class="nx">attr</span><span class="p">)</span> <span class="p">{</span>
					<span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">.</span><span class="nx">setAttribute</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">attr</span><span class="p">[</span><span class="nx">a</span><span class="p">]);</span>
				<span class="p">}</span>
			<span class="p">}</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">clone_fly_shape</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">em</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">.</span><span class="nx">cloneNode</span><span class="p">();</span>
			<span class="nx">em</span><span class="p">.</span><span class="nx">removeAttribute</span><span class="p">(</span><span class="s1">&#39;class&#39;</span><span class="p">);</span>
			<span class="k">return</span> <span class="nx">em</span><span class="p">;</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">fly_end</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_emDrawBox</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span><span class="p">);</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_flyShape</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_flyStart</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * the source element of the event can be anything in SVG. this function</span>
<span class="cm">	 * is used to find the object that the element belong to.</span>
<span class="cm">	 *</span>
<span class="cm">	 * @method find_event_obj</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">find_event_obj</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evt</span><span class="p">)</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="nx">evt</span><span class="p">.</span><span class="nx">srcElement</span><span class="p">;</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span> <span class="p">(</span><span class="nx">p</span><span class="p">.</span><span class="nx">parentNode</span> <span class="o">!=</span> <span class="kc">null</span> <span class="o">&amp;&amp;</span> <span class="nx">p</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">.</span><span class="nx">tagName</span> <span class="o">!=</span> <span class="s1">&#39;SVG&#39;</span><span class="p">);</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">p</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">.</span><span class="nx">id</span> <span class="o">==</span> <span class="s1">&#39;drawbox&#39;</span><span class="p">)</span> <span class="p">{</span>
				<span class="k">return</span> <span class="nx">p</span><span class="p">;</span>
			<span class="p">}</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="cm">/* ======================================================================</span>
<span class="cm">	 * UNDO and REDO</span>
<span class="cm">	 * ======================================================================</span>
<span class="cm">	 */</span>
	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_push_undo</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">undo</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_undoIndex</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_undoStack</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">_undoStack</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_undoIndex</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_undoStack</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">undo</span><span class="p">);</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">_undoIndex</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_undoStack</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">undo</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">undo</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_undoStack</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span>
		<span class="nx">undo</span><span class="p">.</span><span class="nx">func</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">undo</span><span class="p">.</span><span class="nx">obj</span> <span class="o">||</span> <span class="k">this</span><span class="p">,</span> <span class="p">[</span><span class="nx">undo</span><span class="p">.</span><span class="nx">param</span><span class="p">]);</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">redo</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_undo_steps</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_redo_steps</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
	<span class="p">}</span>

	<span class="nx">SVGBoard</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">clear</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">len</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_drawBox</span><span class="p">.</span><span class="nx">childNodes</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
		<span class="nx">alert</span><span class="p">(</span><span class="nx">len</span><span class="p">);</span>
	<span class="p">}</span>


	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">SVGBoard</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">w</span><span class="p">,</span> <span class="nx">h</span><span class="p">,</span> <span class="nx">u</span><span class="p">)</span> <span class="p">{</span>
		<span class="kd">var</span> <span class="nx">board</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">SVGBoard</span><span class="p">(</span><span class="nx">w</span><span class="p">,</span> <span class="nx">h</span><span class="p">,</span> <span class="nx">u</span><span class="p">);</span>
		<span class="nx">board</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">);</span>
		<span class="k">return</span> <span class="nx">board</span><span class="p">;</span>
	<span class="p">}</span>
 <span class="p">})();</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class="selected"><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_svg.html" title="svg">svg</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class=""><a href="module_utils.html" title="utils">utils</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="DOM.Element.html" title="DOM.Element">DOM.Element</a></li>
                                <li class=""><a href="EventListener.html" title="EventListener">EventListener</a></li>
                                <li class=""><a href="G.html" title="G">G</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="board.js.html" title="board.js">board.js</a></li>
                                <li class=""><a href="dom.js.html" title="dom.js">dom.js</a></li>
                                <li class=""><a href="g.js.html" title="g.js">g.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"url": "EventListener.html#method_bind", "access": "", "host": "EventListener", "type": "method", "name": "bind"}, {"url": "DOM.Element.html#method_disable_drag", "access": "", "host": "DOM.Element", "type": "method", "name": "disable_drag"}, {"url": "DOM.Element.html#method_enable_drag", "access": "", "host": "DOM.Element", "type": "method", "name": "enable_drag"}, {"url": "EventListener.html#method_fire", "access": "", "host": "EventListener", "type": "method", "name": "fire"}, {"url": "G.html#method_GClass", "access": "", "host": "G", "type": "method", "name": "GClass"}, {"url": "DOM.Element.html#method_get_mouse", "access": "", "host": "DOM.Element", "type": "method", "name": "get_mouse"}, {"url": "DOM.Element.html#method_get_offset_in_page", "access": "", "host": "DOM.Element", "type": "method", "name": "get_offset_in_page"}, {"url": "G.html#method_get_uuid", "access": "", "host": "G", "type": "method", "name": "get_uuid"}, {"url": "DOM.Element.html#method___init", "access": "", "host": "DOM.Element", "type": "method", "name": "__init"}, {"url": "EventListener.html#method___listen", "access": "", "host": "EventListener", "type": "method", "name": "__listen"}, {"url": "G.html#method_Namespace", "access": "", "host": "G", "type": "method", "name": "Namespace"}, {"url": "DOM.Element.html#method_reg_resize_check", "access": "", "host": "DOM.Element", "type": "method", "name": "reg_resize_check"}, {"url": "EventListener.html#method_unbind", "access": "", "host": "EventListener", "type": "method", "name": "unbind"}, {"url": "EventListener.html#method___unlisten", "access": "", "host": "EventListener", "type": "method", "name": "__unlisten"}, {"url": "DOM.Element.html#method_unreg_resize_check", "access": "", "host": "DOM.Element", "type": "method", "name": "unreg_resize_check"}];
</script>
</body>
</html>
